<template>
  <div class="article-editor">
    <el-form ref="form" :model="form" label-width="80px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="标题">
            <el-input v-model="form.name"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="4">
          <el-form-item label="分类">
            <el-select v-model="form.region" placeholder="请选择分类">
              <el-option label="日志" value="log"></el-option>
              <el-option label="数据结构" value="dataStructure"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="是否置顶">
            <el-switch v-model="form.top"></el-switch>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="标签">
            <el-checkbox-group v-model="form.tips">
              <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
              <el-checkbox label="地推活动" name="type"></el-checkbox>
              <el-checkbox label="线下主题活动" name="type"></el-checkbox>
              <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-col>
      </el-row>
      <h3>正文编辑</h3>
      <quill-editor ref="text" v-model="form.content" class="myQuillEditor" :options="editorOption"></quill-editor>
      <br>
      <br>
      <br>
      <el-button type="primary" @click="onSubmit">立即创建</el-button>
      <el-button type="primary" @click="onPreview">预览</el-button>
      <el-button>取消</el-button>

    </el-form>
  </div>
</template>

<script>
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

import { quillEditor } from 'vue-quill-editor'

export default {
  name: 'ArticleEditor',
  components: {
    quillEditor
  },
  data () {
    return {
      editorOption: {},
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        top: false,
        tips: [],
        resource: '',
        desc: '',
        content: ''
      }
    }
  },
  methods: {
    onSubmit () {
      console.log('submit!')
    }
  }
}
</script>

<style scoped>
  .myQuillEditor{
    height: 20rem;
  }
</style>
